<?php
include("_mysql.php");
include("_settings.php");
include("_functions.php");

if(isset($_POST)) {
	$comment = $_POST["comment"];
	$newsID = $_POST["newsID"];
	$poster = 1;
	//Insert data
	safe_query("INSERT INTO comments(ID, newsID, content, poster, replyTo, date) VALUES (null, '".$newsID."', '".$comment."', ".$poster.", 0, UNIX_TIMESTAMP())");
	$commentID = mysql_insert_id();
	$result = safe_query("SELECT comments.*, user.username FROM comments LEFT JOIN user ON comments.poster = user.userID WHERE ID = " . $commentID);
	$comment = mysql_fetch_assoc($result);
?>
						<li class="parent">
							<div class="commentWrap">
								<h4><?=$comment["username"]?></h4>
								<div class="commentContent">
									<?=$comment["content"]?> 
								</div>
								<div class="commentExInfo clearafter">
									<span><?=ago($comment["date"])?></span>
									<div class="right">
										<a href="#">Like</a>
										<a href="#">Reply</a>
									</div>
								</div>
							</div>							
						</li>
<?php 
}
?>